﻿Public Class frmRechAdj

    Private Sub txtPrix_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtRech.TextChanged
        lstViwAdjoint.Items.Clear()
        Try
            If Not String.IsNullOrWhiteSpace(txtRech.Text) And Not String.IsNullOrEmpty(txtRech.Text) Then

                Dim enregi As String 'Récupère une ligne entier de la liste

                Dim i As Integer = 0 ' le nombre de case pour la table des parain trouvé
                For Each adj In lstAdjoints
                    enregi = adj.nom & " " & adj.prenom & " " & adj.professino

                    If enregi.IndexOf(txtRech.Text, 0, enregi.Length, StringComparison.CurrentCultureIgnoreCase) > -1 Then
                        Dim Line As ListViewItem = New ListViewItem(New String() {adj.idAdjoint, adj.nom, adj.prenom, adj.professino})
                        lstViwAdjoint.Items.Add(Line)
                    End If
                Next
            End If
        Catch ex As Exception
            MsgBox("Une erreur c'est produite, veuillez informer l'administrateur de l'application !!!" & Environment.NewLine & "Déscription de l'erreur :" & Environment.NewLine & ex.Message, MsgBoxStyle.Critical, "Erreur")
        End Try
    End Sub

    Private Sub frmRechParrai_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        frm.Enabled = True
    End Sub

    Private Sub lstViwParrai_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstViwAdjoint.DoubleClick
        Try
            idClt = CInt(lstViwAdjoint.SelectedItems(0).SubItems(0).Text)
            Dim grb As IEnumerable(Of Control) = From c As Control In frm.Controls Where c.Name = "grbAdj"

            Dim cmb As IEnumerable(Of Control) = From c As Control In grb(0).Controls Where c.Name = "cmbAdjoint"


            For Each it As DictionaryEntry In CType(cmb(0), ComboBox).Items
                If it.Key = idClt Then
                    CType(cmb(0), ComboBox).SelectedItem = it
                    Exit For
                End If
            Next
            Me.Close()
        Catch ex As Exception
            MsgBox("Une erreur c'est produite, veuillez informer l'administrateur de l'application !!!" & Environment.NewLine & "Déscription de l'erreur :" & Environment.NewLine & ex.Message, MsgBoxStyle.Critical, "Erreur")
        End Try
    End Sub
End Class